import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/element/index'

Vue.config.productionTip = false

import VueQuillEditor from 'vue-quill-editor'

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

Vue.use(VueQuillEditor, /* { default global options } */)
import result from '@/components/myLoading/index'
Vue.use(result);



router.beforeEach((to, from, next) => {
  let token = localStorage.getItem('token');
  if (token != null) {
    token = JSON.parse(token)
    let times = new Date().getTime() - token.time;
    if (times > token.prescription) {
      localStorage.removeItem('token')
      next({
        path: '/login',
        meta: {
          path: to.path
        }
      })
    }
  } else {
    if (to.path == '/login' || !to.meta.flag) {
      next()
    } else {
      next({
        path: '/login',
        meta: {
          path: to.path
        }
      })
    }
  }
  next()
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
